<?php
/**
 * A compound {@link Element pOHA object}s. These objects are made up
 * from base pOHA objects but no Compound objects.
 *
 * @version		1.0
 * @author 		Bernard Leckning <bernard@dorja.com>
 * @package		pOHA
 * @subpackage	Compound
 */


/**
 * Base pOHA {@link pOHACompound.php Compound} package.
 */
include_once('pOHA.php');


/**
 * A compound {@link Element pOHA object}.
 *
 * @version		1.0
 * @author 		Bernard Leckning <bernard@dorja.com>
 * @package		pOHA
 * @subpackage	Compound
 */
class HTMLAnchoredListItem extends HTMLListItem
{
	function HTMLAnchoredListItem($content, $url, $target = '', $name = '', $class = '', $id = '')
	{
		$a = new HTMLAnchor($url, $content, $target, $name);
		parent::HTMLListItem($a, $class, $id);
	}
}


/**
 *	A compound {@link Element pOHA object}.
 *
 * @version		1.0
 * @author 		Bernard Leckning <bernard@dorja.com>
 * @package		pOHA
 * @subpackage	Compound
 */
class HTMLImageAnchor extends HTMLAnchor
{
	function HTMLImageAnchor(	$source,
								$alt,
								$url,
								$height = '',
								$width = '',
								$target = '',
								$name = '',
								$class = '',
								$id = ''
							)
	{
		$img = new HTMLImage($source, $alt, $height, $width);
		parent::HTMLAnchor($url, $img, $target, $name, $class, $id);
	}
}


/**
 * A compound {@link Element pOHA object}.
 *
 * @version		1.0
 * @author 		Bernard Leckning <bernard@dorja.com>
 * @package		pOHA
 * @subpackage	Compound
 */
class HTMLLabelledImageButton extends HTMLInputButton
{
	function HTMLLabelledImageButton(	$source,
										$label,
										$name,
										$value,
										$type = 'button',
										$height ='',
										$width = '',
										$class = '',
										$id
									)
	{
		$img = new HTMLImage($source, '', $height, $width);
		parent::HTMLButton($name, $value, array($img, $label), $type, $class, $id);
	}
}


/**
 * A compound {@link Element pOHA object}.
 *
 * @version		1.0
 * @author 		Bernard Leckning <bernard@dorja.com>
 * @package		pOHA
 * @subpackage	Compound
 */
class HTMLLabelledImageSubmitButton extends HTMLLabelledImageButton
{
	function HTMLLabelledImageSubmitButton	(	$source,
												$label,
												$name,
												$value,
												$height ='',
												$width = '',
												$class = '',
												$id = ''
											)
	{
		parent::HTMLLabelledImageButton	(	$source ,
											$label,
											$name,
											$value,
											'submit',
											$height,
											$width,
											$class,
											$id
										);
	}
}


/**
 * Format a form input with a label.
 *
 * This takes a form input and lays it out with a label and wraps it
 * up in DIVs and SPANS. The layout is taken from {@link http://www.alistapart.com/stories/practicalcss/ Practical CSS Layout Tips, Tricks and Techniques}
 * which recommends tag structure for flexable form layout with CSS.
 *
 *	@version	1.0
 *	@author		Alexander R B Whillas BSCS <dev@tsd.net.au>
 * @package 	pOHA
 * @subpackage	Extended
 */
class HTMLLabeledInput extends HTMLBlock
{
	/**
	 * Given a form input of some type, lays it out with a label.
	 * 
	 * @param	pOHA	HTMLInput or one of its decendants.
	 * @param	string	Text label associated with the input control.
	 * @param	string	The value of the class attribute to assign to this image pOHA object.
	 * @param	string	The value of the id attribute to assign to this image pOHA object.	 
	 * @access	public
	 */
	function HTMLLabeledInput($input, $caption, $class = 'labeledInput', $id = '')
	{
		if (is_a($input, 'HTMLInput'))
		{
			if(!$control_id = $input->getAttribute('id'))
			{
				$control_id = $input->getAttribute('name');
				$input->setAttribute('id', $control_id);
			}
		}
		else
			$control_id = '';
		
		$l = new HTMLBlock(new HTMLInputLabel($caption, $control_id), 'inputLabel',	$control_id.'Label', FALSE);
		$c = new HTMLBlock($input, 'inputControl',$control_id.'Control', FALSE);
		
		return parent::HTMLBlock(array($l, $c), $class, $id);
	}
}


?>